using Microsoft.AspNetCore.Mvc;
using ZR.Model.Dto;
using ZR.Service.Business.IBusinessService;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;

//创建时间：2024-09-29
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 操作类型点位详情配置
    /// </summary>
    [Verify]
    [Route("formula/operationpointconfig")]
    [ApiExplorerSettings(GroupName = "business")]
    public class OperationPointConfigController : BaseController
    {
        /// <summary>
        /// 操作类型点位详情配置接口
        /// </summary>
        private readonly IOperationPointConfigService _OperationPointConfigService;

        public OperationPointConfigController(IOperationPointConfigService OperationPointConfigService)
        {
            _OperationPointConfigService = OperationPointConfigService;
        }

        /// <summary>
        /// 查询操作类型点位详情配置列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "formula:operationpointconfig:list")]
        public IActionResult QueryOperationPointConfig([FromQuery] OperationPointConfigQueryDto parm)
        {
            var response = _OperationPointConfigService.GetList(parm);
            return SUCCESS(response);
        }

        /// <summary>
        /// 查询操作类型点位详情配置详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "formula:operationpointconfig:query")]
        public IActionResult GetOperationPointConfig(int Id)
        {
            var response = _OperationPointConfigService.GetInfo(Id);

            var info = response.Adapt<OperationPointConfigDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加操作类型点位详情配置
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "formula:operationpointconfig:add")]
        [Log(Title = "操作类型点位详情配置", BusinessType = BusinessType.INSERT)]
        public IActionResult AddOperationPointConfig([FromBody] OperationPointConfigDto parm)
        {
            var modal = parm.Adapt<OperationPointConfig>().ToCreate(HttpContext);

            var response = _OperationPointConfigService.AddOperationPointConfig(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新操作类型点位详情配置
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "formula:operationpointconfig:edit")]
        [Log(Title = "操作类型点位详情配置", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateOperationPointConfig([FromBody] OperationPointConfigDto parm)
        {
            var modal = parm.Adapt<OperationPointConfig>().ToUpdate(HttpContext);
            var response = _OperationPointConfigService.UpdateOperationPointConfig(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除操作类型点位详情配置
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "formula:operationpointconfig:delete")]
        [Log(Title = "操作类型点位详情配置", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteOperationPointConfig([FromRoute] string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_OperationPointConfigService.Delete(idArr));
        }
    }
}